#ifndef CUBEPREDICT_H
#define CUBEPREDICT_H
#include "cubeResolve.h"
using namespace std;

class CubePredict {
public:
	Sint3D *v_past;	// Esquinas del subcubo pasadas
	// 		*v_now,		// Esquinas del subcubo actuales
	// 		*v_future;// Esquinas del subcubo estimadas
	CubePredict(Sint3D* vertex = NULL){
		v_past = new Sint3D[8];	// Esquinas del subcubo pasadas
		// 		v_now = new Sint3D[8];		// Esquinas del subcubo actuales
		// 		v_future = new Sint3D[8];// Esquinas del subcubo estimadas
		if (vertex != NULL) {
			for (char i = 0 ; i < 8 ; i++) {
				v_past[i] = vertex[i];
			}
		}
	}
	~CubePredict() {
		DeleteA(v_past);
// 		DeleteA(v_now);
// 		DeleteA(v_future);
	}
	void predict(Sint3D* now, Sint3D* future){
		if (now == NULL || future == NULL) {
			return;
		}
		for (char i = 0 ; i < 8 ; i++) {
			future[i].x = 2*now[i].x-v_past[i].x;
			future[i].y = 2*now[i].y-v_past[i].y;
			future[i].z = 2*now[i].z-v_past[i].z;
			v_past[i] = now[i];
		}
		return;
	}
};

#endif //CUBEPREDICT_H


	/*	Sint3D* predict(Sint3D* vertex = NULL){
	bool nullArg = false;
	if (vertex == NULL) {
	vertex = new Sint3D[8];
	nullArg = true;
	}
	for (char i = 0 ; i < 8 ; i++) {
	if (!nullArg) {
	v_now[i] = vertex[i];
	}
	v_future[i].x = 2*v_now[i].x-v_past[i].x;
	v_future[i].y = 2*v_now[i].y-v_past[i].y;
	v_future[i].z = 2*v_now[i].z-v_past[i].z;
	v_past[i] = v_now[i];
	vertex[i] = v_future[i];
	}
	// 		if (!nullArg) {
	return vertex;
	// 		} else {
	// 			return v_future;
	// 		}
	char i, j, k;
	for (i = 0 ; i < 2; i++){
	for (j = 0 ; j < 2; j++){
	for (k = 0 ; k < 2; k++){
	*(v_past+(i*4+j*2+k)) = 
	*(v_now+(i*4+j*2+k)) = 
	*(v_future+(i*4+j*2+k)) = 
	Sint3D(k?int(resolution.x):0,j?int(resolution.y):0,i?int(resolution.z):0);
	}
	}
	}
	*/